package com.sumainfor.common.utlis;

import com.sumainfor.common.entity.DataFilterEntity;
import com.sumainfor.common.exception.TCException;

import java.util.Map;

/**
 * @Author Jack Chen
 * @Create 2019-01-16 14:52
 * 数据权限 自定义工具类
 */
public final class ParamsDataFilterUtil {

    /**
     * 存放Data Filter 对象的Key值
     */
    public static final String DATA_FILTER_KEY = "DATA_FILTER_ENTITY_KEY";


    /**
     * 构建添加数据过滤包装工具
     *
     * @param params
     * @param filterEntity
     * @return
     */
    public static final Map<String, Object> buildSelectDataFilter(Map<String, Object> params, DataFilterEntity filterEntity) {
        if (filterEntity == null || params == null) {
            throw new TCException("数据权限过滤不能为空");
        }
        params.put(DATA_FILTER_KEY, filterEntity);
        return params;
    }
}
